#include "SeqStack.h"

template<class T>
SeqStack<T> *SeqStack<T>::Init_SeqStack() {
    for(int i = 0;i < MAX_SIZE;i++) {
        this->data[i] = NULL;
    }

    this->size = 0;

    return this;
}

template<class T>
void SeqStack<T>::Push_SeqStack(T *data) {
    if(this == NULL) return;
    if(data == NULL) return;
    if(this->size == MAX_SIZE) return;

    this->data[this->size] = data;
    this->size++;
}

template<class T>
T *SeqStack<T>::Top_SeqStack() {
    if(this == NULL) return NULL;
    if(this->size == 0) return NULL;

    return this->data[this->size - 1];
}

template<class T>
T *SeqStack<T>::Pop_SeqStack() {
    if(this == NULL) return NULL;
    if(this->size == 0) return NULL;

    T* save = this->data[this->size - 1];

    this->data[this->size - 1] = NULL;
    this->size--;
    return save;
}

template<class T>
bool SeqStack<T>::IsEmpty() {
    if(this == NULL) return false;
    if(this->size == 0) return true;
    return false;
}

template<class T>
int SeqStack<T>::Size_SeqStack() {
    if(this == NULL) return -1;
    return this->size;
}

template<class T>
void SeqStack<T>::FreeSpace_SeqStack() {
    if(this == NULL) return;

    delete this;
}

template<class T>
void SeqStack<T>::Clear_SeqStack() {
    if(this == NULL) return;

    for(int i = 0;i < this->size;i++) {
        this->data[i] = NULL;
    }
    this->size = 0;
}
